home *** CD-ROM | disk | FTP | other *** search
- /* UploadFromDopus.thor by Troels Walsted Hansen
- ** $VER: UploadFromDopus.thor v2.01 (16.01.95)
- **
- ** An ARexx script that gets the name of selected files in Dopus
- ** and creates upload events for those in Thor. Supports the AmiNet
- ** standard of getting the short and long description from a special
- ** .readme file. If no .readme file is around, the script will attempt
- ** to obtain a short description from the filecomment of the file.
- **
- ** Known to work with DirOpus v4.12.
- **
- ** New: This version is only for THOR v2.0 or higher.
- **
- ** New for v2.01: Works with filecomments again.
- */
-
- /* user variables. edit to your hearts content */
-
- bbs = "REQUEST" /* If you always upload files to the same BBS, */
- /* change REQUEST to the name of that BBS.. */
-
- options results
-
- /* needs THOR, bbsread.library and Dopus functions */
-
- p = ' ' || address() || ' ' || show('P',,)
- thorport = pos(' THOR.',p)
-
- if thorport > 0 then thorport = word(substr(p,thorport+1),1)
- else
- do
- say 'No THOR port found!'
- exit 10
- end
-
- if ~show('p', 'BBSREAD') then
- do
- address command
- "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
- "WaitForPort BBSREAD"
- end
-
- if ~show('ports','DOPUS.1') then do
- say "DirectoryOpus' ARexx port was not found. Aborting script.."
- exit
- end
-
- /* main stuff */
-
- address DOPUS.1
-
- STATUS 7 "-1"
- NumberOfSelected = result
-
- if(NumberOfSelected = 0) then do
- NOTIFY "Please select some files first..."
- exit
- end
-
- STATUS 13 "-1"
- FilePath = result
-
- if(bbs = "REQUEST") then do
- address(bbsread)
- GETBBSLIST stem BBSLIST
- if(rc ~= 0) then
- do
- address(thorport)
- REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
- exit 5
- end
-
- address(thorport)
- REQUESTLIST instem BBSLIST title '"Select BBS:"' SIZEGADGET
- if(rc ~= 0) then exit
- else bbs = result
- end
-
- REQUESTNOTIFY TEXT '"Enable private to conference uploading?"' BT '"_Yes|_No"'
- AskForConfname = result
-
- address(bbsread)
- GETBBSDATA '"'bbs'"' stem BBSDATA
-
- address DOPUS.1
-
- do i=1 until i = NumberOfSelected
- drop EVENT.
- EVENT.FILEDESCR = ""
-
- GETNEXTSELECTED
- EVENT.FILENAME = result
- EVENT.LOCALFILE = FilePath || EVENT.FILENAME
- orgfilename = EVENT.FILENAME
-
- if(AskForConfname) then do
- address(bbsread)
- GETCONFLIST '"'bbs'"' CONFLIST
- if(rc ~= 0) then
- do
- address(thorport)
- REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
- exit 5
- end
-
- address(thorport)
- REQUESTLIST instem CONFLIST title '"Select conf:"' SIZEGADGET
- if(rc ~= 0) then break
- else EVENT.CONFERENCE = result
- end
-
- filenamelength = length(EVENT.FILENAME)
-
- /* this is only a temporary solution */
-
- if(BBSDATA.BBSTYPE = "ABBS"|BBSDATA.BBSTYPE = "ABBS_QWK") then do
- if(filenamelength > 16) then do
- address(thorport)
- REQUESTSTRING TITLE '"Please shorten filename to 16 chars:"' BT '"_Ok|_Cancel"' ID '"'EVENT.FILENAME'"' MAXCHARS 100
- if(rc ~= 0) then exit
- else EVENT.FILENAME = result
- end
- end
-
- if(BBSDATA.BBSTYPE = "MBBS"|BBSDATA.BBSTYPE = "MBBS_QWK") then do
- if(filenamelength > 13) then do
- address(thorport)
- REQUESTSTRING TITLE '"Please shorten filename to 8+3 chars:"' BT '"_Ok|_Cancel"' ID '"'EVENT.FILENAME'"' MAXCHARS 100
- if(rc ~= 0) then exit
- else EVENT.FILENAME = result
- end
- end
-
- address DOPUS.1
- DOPUSTOFRONT
-
- TOPTEXT "Creating upload event for """EVENT.FILENAME"""..."
- EVENT.DETAILEDFILEDESCR = FilePath||substr(EVENT.FILENAME, 1, lastpos(".",EVENT.FILENAME))||"readme"
-
- if exists(EVENT.DETAILEDFILEDESCR) then do
- address(bbsread)
- UNIQUEMSGFILE bbsname '"'bbs'"' stem UNIQUEFILE
- if(rc ~= 0) then
- do
- address(thorport)
- REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
- exit
- end
-
- address command 'copy >nil: ' || '"' || EVENT.DETAILEDFILEDESCR || '"' || ' TO ' || '"' || UNIQUEFILE.NAME || '"'
- EVENT.DETAILEDFILEDESCR = UNIQUEFILE.NAME
-
- call open(ReadMe, EVENT.DETAILEDFILEDESCR, R)
-
- do while(~eof(ReadME) & EVENT.FILEDESCR = "")
- Line = readln(ReadMe)
- if(upper(substr(Line,1,6)) = "SHORT:") then EVENT.FILEDESCR = strip(substr(Line,8),B)
- end
-
- call close(ReadMe)
- end
- else drop EVENT.DETAILEDFILEDESCR
-
- if(EVENT.FILEDESCR = "") then do
- address command 'list ' || '"' || FilePath || orgfilename || '"' || ' lformat="%C" >t:TempFilecommentFile'
-
- if(rc = 0) then
- do
- call open(tfh,"t:TempFilecommentFile", R)
- EVENT.FILEDESCR = readln(tfh)
- call close(tfh)
- end
-
- address command "delete >nil: t:TempFilecommentFile"
-
- if(EVENT.FILEDESCR = "") then do
- address(thorport)
- REQUESTSTRING TITLE '"'||'Enter description for: '||EVENT.FILENAME||'"' BT '"_Ok|_Cancel"' MAXCHARS 40
- if(rc ~= 0) then exit
- else EVENT.FILEDESCR = result
- end
- end
-
- address(bbsread)
- WRITEBREVENT bbsname '"'bbs'"' event 5 stem EVENT
- if(rc ~= 0) then
- do
- address(thorport)
- REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
- exit 5
- end
-
- address DOPUS.1
- SELECTFILE '"'orgfilename'"' 0 1
- end
-
- exit
-